package cfca.paperless.client.servlet._3_assist._3_17_GetAdvertisementInfoList;

import cfca.paperless.client.servlet.PaperlessClient;
import cfca.paperless.client.servlet.PaperlessConfig;
import cfca.paperless.client.util.StringUtil;

public class GetAdvertisementInfoListTest01 {

    public static void main(String[] args) throws Exception {
        try {
            PaperlessClient clientBean = new PaperlessClient(PaperlessConfig.assistUrl, 10000, 60000);// 无纸化辅助接口的访问URL

            // 操作员编码或者机构号
            String operatorCode = PaperlessConfig.operatorCode;

            String requestXml = "<Request>" + "<HashAlg>md5</HashAlg>" + "</Request>";

            String result = clientBean.getAdvertisementInfoList(requestXml, operatorCode);
            String code = StringUtil.getNodeText(result, "Code");
            if (!code.equals("200")) {
                System.out.println("getAdvertisementList");
                System.out.println(result);
            } else {
                Object[] objArr = StringUtil.getXmlFieldArr(result, "Advertisement");
                for (Object obj : objArr) {

                    System.out.println("===============================");
                    String adCode = StringUtil.getXmlField(obj.toString(), "Code");
                    System.out.println("Code:"+adCode);
                    String adName = StringUtil.getXmlField(obj.toString(), "Name");
                    System.out.println("Name:"+adName);
                    String fileFormat = StringUtil.getXmlField(obj.toString(), "FileFormat");
                    System.out.println("FileFormat:"+fileFormat);
                    String type = StringUtil.getXmlField(obj.toString(), "Type");
                    System.out.println("Type:"+type);
                    String version = StringUtil.getXmlField(obj.toString(), "Version");
                    System.out.println("Version:"+version);
                    String status = StringUtil.getXmlField(obj.toString(), "Status");
                    System.out.println("Status:"+ status);
                    String hashValue = null;
                    try {
                        hashValue = StringUtil.getXmlField(obj.toString(), "HashValue");
                        System.out.println("HashValue:" + hashValue);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
            
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
